package com.csrcb.tools;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;

/**
 * @Classname StreamHandler
 * @Description 流处理
 * @Date 2020/12/16 13:34
 * @Created by gangye
 */
public class StreamHandler {
    public static void handleCloseStream(OutputStreamWriter osw, InputStream is, BufferedReader br) throws IOException {
        if (is != null) {
            is.close();
        }
        if (osw != null) {
            osw.close();
        }
        if (br != null) {
            br.close();
        }
    }

    public static void handleCloseStream(InputStream is, BufferedReader br) throws IOException {
        handleCloseStream(null, is, br);
    }

    public static void handleCloseStream(OutputStreamWriter osw, BufferedReader br) throws IOException {
        handleCloseStream(osw, null, br);
    }
}
